package com.gaohe.web.controller.scp;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.scp.domain.CsCarQuote;
import com.gaohe.scp.service.ICsCarQuoteService;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.common.core.page.TableDataInfo;

/**
 * 车辆报价Controller
 *
 * @author liuxiangyu
 * @date 2025-03-25
 */
@RestController
@RequestMapping("/scp/quote")
public class CsCarQuoteController extends BaseController
{
    @Autowired
    private ICsCarQuoteService csCarQuoteService;

    // 通过carId查询查询车辆报价------牛相善
//    @PreAuthorize("@ss.hasPermi('scp:quote:query')")
    @GetMapping(value = "/car/{carId}")
    public AjaxResult getQuoteByCarId(@PathVariable("carId") Long carId)
    {
        return success(csCarQuoteService.selectCsCarQuoteByCarId(carId));
    }


    /**
     * 查询车辆报价列表
     */
//    @PreAuthorize("@ss.hasPermi('scp:quote:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsCarQuote csCarQuote)
    {
        startPage();
        List<CsCarQuote> list = csCarQuoteService.selectCsCarQuoteList(csCarQuote);
        return getDataTable(list);
    }

    /**
     * 导出车辆报价列表
     */
//    @PreAuthorize("@ss.hasPermi('scp:quote:export')")
    @Log(title = "车辆报价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsCarQuote csCarQuote)
    {
        List<CsCarQuote> list = csCarQuoteService.selectCsCarQuoteList(csCarQuote);
        ExcelUtil<CsCarQuote> util = new ExcelUtil<CsCarQuote>(CsCarQuote.class);
        util.exportExcel(response, list, "车辆报价数据");
    }

    /**
     * 获取车辆报价详细信息
     */
//    @PreAuthorize("@ss.hasPermi('scp:quote:query')")
    @GetMapping(value = "/{quoteId}")
    public AjaxResult getInfo(@PathVariable("quoteId") Long quoteId)
    {
        return success(csCarQuoteService.selectCsCarQuoteByQuoteId(quoteId));
    }

    /**
     * 新增车辆报价
     */
//    @PreAuthorize("@ss.hasPermi('scp:quote:add')")
    @Log(title = "车辆报价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsCarQuote csCarQuote)
    {
        return toAjax(csCarQuoteService.insertCsCarQuote(csCarQuote));
    }

    /**
     * 修改车辆报价
     */
//    @PreAuthorize("@ss.hasPermi('scp:quote:edit')")
    @Log(title = "车辆报价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsCarQuote csCarQuote)
    {
        return toAjax(csCarQuoteService.updateCsCarQuote(csCarQuote));
    }

    /**
     * 删除车辆报价
     */
//    @PreAuthorize("@ss.hasPermi('scp:quote:remove')")
    @Log(title = "车辆报价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{quoteIds}")
    public AjaxResult remove(@PathVariable Long[] quoteIds)
    {
        return toAjax(csCarQuoteService.deleteCsCarQuoteByQuoteIds(quoteIds));
    }
}
